<%@ page contentType="text/html;charset=UTF-8"%>
<%@include file="../../common/sessionValidate.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html lang="UTF-8">
  <head>
    <title>T_goods信息维护</title>
    <%@ include file="../../common/meta.jsp"%>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="X-UA-Compatible" content="IE=9">
	<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <link rel="stylesheet" href="<%=basePath%>css/my-bootstrap.css" media="screen"  id="tuserskin">
    <link rel="stylesheet" href="<%=basePath%>js/toastr/toastr.css">
    <link rel="stylesheet" href="<%=basePath%>css/bootstrapValidator.min.css">
    <link rel="stylesheet" href="<%=basePath%>css/font-awesome.min.css">
    <script type="text/javascript" src="<%= basePath %>js/jquery.cookie.js"></script>
  </head>
  <style>
hr {
    margin-top:1px;
    border-bottom: 1px solid #1BBC9B;
}

/*商品属性选项css start*/
*{margin:0;padding:0;list-style-type:none;}
a,img{border:0;}
body{font:12px/180% Arial, Helvetica, sans-serif, "新宋体";}
/* select */
.select{padding:5px 10px;border:#ddd 1px solid;border-radius:4px;width:60%;margin:5% auto;font-size:12px}
.select li{list-style:none;padding:10px 0 5px 100px}
.select .select-list{border-bottom:#eee 1px dashed}
.select dl{zoom:1;position:relative;line-height:24px;}
.select dl:after{content:" ";display:block;clear:both;height:0;overflow:hidden}
.select dt{width:100px;margin-bottom:5px;position:absolute;top:0;left:-100px;text-align:right;color:#666;height:24px;line-height:24px}
.select dd{float:left;display:inline;margin:0 0 5px 5px;}
.select a{display:inline-block;white-space:nowrap;height:24px;padding:0 10px;text-decoration:none;color:#039;border-radius:2px;}
.select a:hover{color:#f60;background-color:#f3edc2}
.select .selected a{color:#fff;background-color:#f60}
.select-result dt{font-weight:bold}
.select-no{color:#999}
.select .select-result a{padding-right:20px;background:#f60 url("close.gif") right 9px no-repeat}
.select .select-result a:hover{background-position:right -15px}
/*商品属性选项css end*/
  </style>
  <body>
  <form class="form-horizontal form-bordered form-row-strippe" name="ffAdd" id="ffAdd" mentod="post" role="form" data-toggle="validator" enctype="multipart/form-data">
  <div class="" style="margin-right:2px;padding-right:1px;">

   <!-------------------------- 面板  start--------------------------------->
	<div class="panel panel-primary" >
	  <div class="panel-heading clearfix"  id="addHeaderDiv">
	  </div>
	  <div class="panel-body">
           <div class="row" >
                <h5>&nbsp;&nbsp;基本信息</h5>
	            <hr>
            	<div class="col-xs-6"><!--start 换列-->
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3">产品id</label>
                            <div class="col-xs-9">
                                <input id="goods_id" name="goods_id" type="text" class="form-control" placeholder="goods_id" readonly="true" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3">商品名称</label>
                            <div class="col-xs-9">
                                <input id="goods_name" name="goods_name" type="text" class="form-control" placeholder="goods_name"  readonly="true"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3">京东价格</label>
                            <div class="col-xs-9">
                                <input id="old_price" name="old_price" type="text" class="form-control" placeholder="old_price"  readonly="true"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3">发货价</label>
                            <div class="col-xs-9">
                                <input id="price" name="price" type="text" class="form-control" placeholder="price"  readonly="true"/>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="col-xs-6">
				<!--如果输入元素是奇数个元素，在n=size/2?int时输出2列格式；如果元素是奇数个，需要在n=size/2?int+1时输出2列格式；需要换列，每行最多显示2列-->
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"><font color="red">*</font>是/否积分商品</label>
                            <div class="col-xs-9">
				              	<select name="isnew" type="text" class="form-control">
				              		<option value="9">是</option>
				                    <option value="">否</option>
				              	</select>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3">批发商</label>
                            <div class="col-xs-9">
								<input id="customer_name" name="customer_name" type="text" class="form-control" placeholder="isnew"  readonly="true"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3">数量</label>
                            <div class="col-xs-9">
                                <input id="num" name="num" type="text" class="form-control" placeholder="num" readonly="true"/>
                            </div>
                        </div>
                    </div>
				</div><!--end 换列-->
            </div><!--end row-->
       </div><!--end body-->

	   <div class="modal-footer bg-info " id='buttonDiv'>
	   </div>
    </div>
    <!--------------------------面板 end------------------------------------>

  </div>
  </form>
  </body>
</html>

<!--<script src="<%=basePath%>js/jquery-1.10.2/jquery.min.js"></script>-->
<script src="<%=basePath%>js/bootstrap.min.js"></script>
<!--<script type="text/javascript" src="js/bootstrapValidator.js"></script>-->
<script src="<%=basePath%>js/bootstrap-paginator.min.js"></script>
<script src="<%=basePath%>/js/respond.js"></script>
<script src="<%=basePath%>/js/html5.js"></script>
<script src="<%=basePath%>js/toastr/toastr.js"></script>
<script src="<%=basePath%>js/bootbox.js"></script>
<script src="<%=basePath%>js/jquery.validate.js"></script>
<!-- <script src="<%=basePath%>js/additional-methods.min.js"></script> -->
<script src="<%=basePath%>js/my-jquery-curd.js"></script>
<script src="<%= basePath %>js/tableSortTool.js" ></script>
<script src="<%= basePath %>js/calendar.js" ></script>
<script type="text/javascript">
//新增保存数据
function add() {
	//$("#addSaveButton").attr("disabled", true);
	var url = "<%=basePath%>t_goods/saveT_goods?time="+Math.random();
	var postData = $("#ffAdd").serializeArray();
	//alert(postData);
    $.post(url, postData, function (data) {
    	//var data = $.parseJSON(data);
        if (data.result=="success") {
            //保存成功  1.关闭弹出层，
          	showSuccessTips("恭喜保存成功!", "提示");
        }
        else {
            //$("#addSaveButton").removeAttr("disabled");
        	showErrorTips("保存数据失败!", "错误信息：");
        	return false;
        }
    }).error(function () {
        //$("#addSaveButton").removeAttr("disabled");
    	showErrorTips("保存数据失败!", "错误信息：");
    });
}

//更新修改数据到后台
function edit(){
	$("#editSaveButton").attr("disabled", true);
	var url = "<%=basePath%>t_goods/updateT_ads_goods?time="+Math.random();
	myEdit2(url);
}

function checkFun(spec_id, spec_option_id){
	 var ischecked = $("#"+spec_option_id).is(":checked");
	 alert(ischecked+";spec_id="+spec_id);
	 //var siblingsObj =  $("#"+spec_id).siblings();
	 var siblingsObj = $(":checkbox[name='"+spec_id+"']").siblings();
	 //alert(JSON.stringify(siblingsObj) );
	 if(ischecked==false){
		//alert(" checkFun spec_option_id="+spec_option_id);
		//$("#"+spec_id).siblings().attr("checked",false);
		//$("#"+spec_option_id).attr("checked",true);
	}else{
		//$("#"+spec_id).siblings().attr("checked",false);
		//$("#"+spec_option_id).attr("checked",false);
	}

	 if(ischecked){
		 alert("111111111"+"------siblings="+JSON.stringify(siblingsObj));
		 $("input[name='"+spec_id+"']").siblings().prop("checked",false);
		 //$("#"+spec_id).siblings().prop("checked",false);
		 $("#"+spec_option_id).prop("checked",false);
		 //alert($(this).val());
	 }else{
		 alert("222222222"+"------siblings="+JSON.stringify(siblingsObj));
		 //$("#"+spec_id).siblings().prop("checked",false);
		 $("input[name='"+spec_id+"']").siblings().prop("checked",false);
		 $("#"+spec_option_id).prop("checked",true);
	 }

}


//初始化页面及校验
$().ready(function(){
	//1、初始化数据显示
	var name = "积分商品";
	var optype ='<%=request.getParameter("oplx")%>';
	var id='<%=request.getParameter("id")%>';
	//alert("optype="+optype+";id="+id);
	var selectItemsOptions; //设置在这里，为了遍历生成js时使用，在数据获取时，先保存在sdata，然后在后面使用。

    if(optype=='edit'){
		var basePath="<i class='icon-pencil'></i>&nbsp;";
		setHeader2("修改"+name, basePath);//设置addHeaderDiv标题文字及按钮
		setButtonDivEdit2();//设置adddiv的 操作按钮
	   	var url = "<%=basePath%>t_goods/getT_goods?id="+id+"&time="+Math.random();
	    $.getJSON(url, function (data) {//获取数据，并且自动填充form，自动代码待修改； @todo;
	    	setValue(data);
	    	//alert($("#effect_date").val()+""+jsonDateFormat($("#effect_date").val()));
	    	//$("#effect_date").val(jsonDateFormat($("#effect_date").val())); //重新设置日期类型的值
	    });
	}

	//2、校验脚本初始化，start check
	$("#ffAdd").validate({
		submitHandler:function(form){
            //alert($("#opType").val());
            if($("#opType").val()=="add"){
            	add();
            }else if($("#opType").val()=="edit"){
            	edit();
            }
	    },
		rules: {
			goods_id: {
			    //required: true,
                digits: true,
			    //minlength: 1,
			    maxlength: 11
    		},
			goods_name: {
			    //required: true,
			    maxlength: 256
    		},
			goods_info: {
			    //required: true,
			    maxlength: 512
    		},
			goods_memo: {
			    //required: true,
			    maxlength: 1024
    		},
			hitscount: {
			    //required: true,
                digits: true,
			    //minlength: 1,
			    maxlength: 11
    		},
			img_path: {
			    //required: true,
			    maxlength: 45
    		},
			old_price: {
			    //required: true,
                number: true,
			    //minlength: 1,
			    maxlength: 22
    		},
			price: {
			    //required: true,
                number: true,
			    //minlength: 1,
			    maxlength: 22
    		},
			num: {
			    //required: true,
                digits: true,
			    //minlength: 1,
			    maxlength: 11
    		},
			salenum: {
			    //required: true,
                digits: true,
			    //minlength: 1,
			    maxlength: 11
    		},
			isnew: {
			    //required: true,
			    maxlength: 45
    		},
			ishot: {
			    //required: true,
			    maxlength: 45
    		},
			product_id: {
			    //required: true,
                digits: true,
			    //minlength: 1,
			    maxlength: 11
    		},
			ext1: {
			    //required: true,
			    maxlength: 128
    		},
			ext2: {
			    //required: true,
			    maxlength: 256
    		},
			ext3: {
			    //required: true,
			    maxlength: 512
    		},
			customer_id: {
			    //required: true,
			    maxlength: 45
    		},
			status: {
			    //required: true,
			    maxlength: 45
    		},
			brandid: {
			    //required: true,
                digits: true,
			    //minlength: 1,
			    maxlength: 11
    		},
			price2: {
			    //required: true,
                number: true,
			    //minlength: 1,
			    maxlength: 22
    		},
			price3: {
			    //required: true,
                number: true,
			    //minlength: 1,
			    maxlength: 22
    		},
			price4: {
			    //required: true,
                number: true,
			    //minlength: 1,
			    maxlength: 22
    		},
			price5: {
			    //required: true,
                number: true,
			    //minlength: 1,
			    maxlength: 22
    		}
	    }, //end rules;
	    messages: {
			goods_id: {
			    //required: "产品id不能为空！",
                digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'>产品id最大支持11位，输入的数据已经超过最大长度！</font>"
    		},
			goods_name: {
			    maxlength: "<font color='red'>名称最大支持256位,输入的数据已经超过最大长度！</font>"
    		},
			goods_info: {
			    maxlength: "<font color='red'>信息最大支持512位,输入的数据已经超过最大长度！</font>"
    		},
			goods_memo: {
			    maxlength: "<font color='red'>详情最大支持1,024位,输入的数据已经超过最大长度！</font>"
    		},
			hitscount: {
			    //required: "卖出量不能为空！",
                digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'>卖出量最大支持11位，输入的数据已经超过最大长度！</font>"
    		},
			img_path: {
			    maxlength: "<font color='red'>图片路径最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			old_price: {
			    //required: true,
                number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'>京东价格最大支持22位,输入的数据已经超过最大长度！</font>"
    		},
			price: {
			    //required: true,
                number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'>价格最大支持22位,输入的数据已经超过最大长度！</font>"
    		},
			num: {
			    //required: "数量不能为空！",
                digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'>数量最大支持11位，输入的数据已经超过最大长度！</font>"
    		},
			salenum: {
			    //required: "销售数量不能为空！",
                digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'>销售数量最大支持11位，输入的数据已经超过最大长度！</font>"
    		},
			isnew: {
			    maxlength: "<font color='red'>新品最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			ishot: {
			    maxlength: "<font color='red'>爆款最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			product_id: {
			    //required: "类别id不能为空！",
                digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'>类别id最大支持11位，输入的数据已经超过最大长度！</font>"
    		},
			ext1: {
			    maxlength: "<font color='red'> ext1最大支持128位,输入的数据已经超过最大长度！</font>"
    		},
			ext2: {
			    maxlength: "<font color='red'> ext2最大支持256位,输入的数据已经超过最大长度！</font>"
    		},
			ext3: {
			    maxlength: "<font color='red'> ext3最大支持512位,输入的数据已经超过最大长度！</font>"
    		},
			customer_id: {
			    maxlength: "<font color='red'> customer_id最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			status: {
			    maxlength: "<font color='red'>状态最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			brandid: {
			    //required: " brandid不能为空！",
                digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'> brandid最大支持11位，输入的数据已经超过最大长度！</font>"
    		},
			price2: {
			    //required: true,
                number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'> price2最大支持22位,输入的数据已经超过最大长度！</font>"
    		},
			price3: {
			    //required: true,
                number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'> price3最大支持22位,输入的数据已经超过最大长度！</font>"
    		},
			price4: {
			    //required: true,
                number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'> price4最大支持22位,输入的数据已经超过最大长度！</font>"
    		},
			price5: {
			    //required: true,
                number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'> price5最大支持22位,输入的数据已经超过最大长度！</font>"
    		}
	   } //end message;
   	}); //end validate;
}) //end funciton read;
</script>
